package com.youyi.yychosesdk.ui.widget;

import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.support.v7.widget.AppCompatTextView;
import android.util.AttributeSet;

public class PressedTextView extends AppCompatTextView {
    private int pressedFlag = 1;
    private float pressedScale = 1.1f;
    private AnimatorSet set;

    public PressedTextView(Context context) {
        super(context);
    }

    public PressedTextView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    public PressedTextView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
    }

    public void setPressed(boolean z) {
        super.setPressed(z);
        if (isPressed()) {
            this.pressedFlag = 1;
            if (this.set == null) {
                AnimatorSet animatorSet = new AnimatorSet();
                this.set = animatorSet;
                animatorSet.setDuration(5L);
            }
            if (this.set.isRunning()) {
                this.set.cancel();
            }
            ObjectAnimator ofFloat = ObjectAnimator.ofFloat(this, "scaleX", 1.0f, this.pressedScale);
            this.set.play(ofFloat).with(ObjectAnimator.ofFloat(this, "scaleY", 1.0f, this.pressedScale));
            this.set.start();
        } else if (this.pressedFlag == 1) {
            this.pressedFlag = 2;
            if (this.set == null) {
                AnimatorSet animatorSet2 = new AnimatorSet();
                this.set = animatorSet2;
                animatorSet2.setDuration(5L);
            }
            if (this.set.isRunning()) {
                this.set.cancel();
            }
            ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(this, "scaleX", this.pressedScale, 1.0f);
            this.set.play(ofFloat2).with(ObjectAnimator.ofFloat(this, "scaleY", this.pressedScale, 1.0f));
            this.set.start();
        }
    }

    public void setPressedScale(float f) {
        this.pressedScale = f;
    }
}
